<script setup>
import {useRouter} from "vue-router";
import {SEARCH_ROUTE} from "@/router/routes/search/search.js";

const router = useRouter()

const props = defineProps({
  title: {type: String, default: '标题'},
  // 顶部导航栏在顶部是否启用元素占位
  placeholder: {type: Boolean, default: false},
  disableSearch: {type: Boolean, default: true},
})

// *******
// * 返回 *
// *******
const goBack = () => {
  router.back()
}

const goSearch = () => {
  router.push({name: SEARCH_ROUTE})
}
</script>

<template>
  <van-nav-bar :title="title" left-text="返回" left-arrow fixed @click-left="goBack" :placeholder="placeholder">
    <template #right>
      <van-icon v-if="!disableSearch" @click="goSearch" name="search" size="20"/>
    </template>
  </van-nav-bar>
</template>

<style scoped lang="scss">

</style>